var mangerMember = avalon.define("manger_member", function(vm) {
	vm.currentTabId = 'student';
	
	vm.permissionSettings = false;
	vm.removeRoles = false;
	vm.downloadBarcode = false;
	
	//权限们
	var competences = {};
	//学生权限
	competences.student = {
		permissionSettings : false,
		removeRoles : false,
		downloadBarcode : false
	};
	//教师权限
	competences.teacher = {
		permissionSettings : true,
		removeRoles : false,
		downloadBarcode : true
	};
	//校长权限
	competences.principal = {
		permissionSettings : true,
		removeRoles : false,
		downloadBarcode : false
	};
	//组长权限
	competences.leader = {
		permissionSettings : true,
		removeRoles : true,
		downloadBarcode : false
	};
	
	//切换左面的tab
	vm.changeTab = function(){
		var tabId = this.getAttribute('data-id');
		if(vm.currentTabId == tabId){
			return;
		}
		vm.currentTabId = tabId;
		$(".membermanger .active").removeClass("active");
		$(this).addClass("active");
		setCompetence(tabId);
	}
	
	//设置权限对话框
	vm.openSetRole = function(){
		$('#member_setrole_model').modal({width : 700});
	}
	//添加成员对话框
	vm.addMember = function(){
		$('#addMember-modal').modal({width : 450});
	}
	
	function setCompetence(tabId){
		var competence = competences[tabId];
		vm.permissionSettings = competence.permissionSettings;
		vm.removeRoles = competence.removeRoles;
		vm.downloadBarcode = competence.downloadBarcode;
	};
	
	setCompetence("student");
});

//设置权限对话框
var memberSetroleModel = avalon.define("member_setrole_model", function(vm) {
	//全选
	vm.selectAll = function(){
		$("#member_setrole_model input[type='checkbox']").prop('checked',true);
	}
	//清空
	vm.clearAll = function(){
		$("#member_setrole_model input[type='checkbox']").prop('checked',false);
	}
});

avalon.scan();

//移除角色
	$('.membermanger .tableArea a.am-icon-times-circle-o').on('click',function(){
		$('#removeMember-modal').modal();
	});
//重置密码
	$('.membermanger .tableArea a.am-icon-shield').on('click',function(){
		$('#resetPwd-modal').modal();
	});
	